<?php

require_once 'smarty_lib/Smarty.class.php';
require_once 'lib/DBClass.php';
require_once 'lib/Account.php';
require_once 'lib/info.php';


$smarty = new Smarty();
$acc = new Account();
$info = new info();



$smarty->template_dir = 'template/';
$smarty->compile_dir = 'template_c/';

if (@$_GET['action'] == 'save') {
	$form = $_POST;
	$add=$info -> addInfo($form);
}



if(!$acc->validate_cookie()){
	$smarty->assign('error','Anda tidak mepunyai akses untuk membuka halaman ini');
	$smarty->display('login.html');
}else{


	if (@$_GET['action'] == 'delete') {
		$id = $_GET['id'];
		$delete = $info->hapusArtikel($id);
	}

	$smarty->assign('cookie', $acc->get_cookie());
	$smarty->assign('page','info.html');
	$smarty->assign('title','Update info');

	$data = $info->get_all_info();
	$smarty->assign('info',$data);
}
$smarty->display('dashboard.html');